package com.qianfeng.chainmobile.api.listeners;

import com.qianfeng.chainmobile.api.event.SendMessageEvent;
import com.qianfeng.chainmobile.api.service.SendMsg2MqService;
import com.qianfeng.smsplatform.common.model.Standard_Submit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@EnableAsync//开启异步
public class SendMessageListener {

    private SendMsg2MqService sendMsg2MqService;
    @Autowired
    public void setSendMsg2MqService(SendMsg2MqService sendMsg2MqService) {
        this.sendMsg2MqService = sendMsg2MqService;
    }
    @EventListener
    @Async//异步执行
    public void onEvent(SendMessageEvent event){
        List<Standard_Submit> standard_submitList = event.getStandard_submitList();
        sendMsg2MqService.sendMessage(standard_submitList);
    }
}
